package com.hq.fxh.No1_Infromation.Video.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.hq.fxh.No0_ChengQu.Activity.BaseActivity;
import com.hq.fxh.No0_ChengQu.Activity.CommentDetailsActivity;
import com.hq.fxh.No1_Infromation.Video.Adapter.Adapter_List_VideoDetail;
import com.hq.fxh.No1_Infromation.Video.Adapter.Help_VideoDetils_Content;
import com.hq.fxh.No1_Infromation.Video.Adapter.Help_VideoDetils_TuiJian;
import com.hq.fxh.Modle.GetEntertainmentListResInfo;
import com.hq.fxh.R;
import com.hq.fxh.Utils.ClickUtils;

import com.hq.fxh.CustomerView.ShareDialogUtils;


import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;



public class VideoDetailsActivity extends BaseActivity implements View.OnClickListener {

    protected LinearLayout detailBack;
    protected LinearLayout detailMore;
    protected ListView recycleVideodetail;
    protected TextView imageNewsDetailsWrite;
    protected LinearLayout imageNewsDetailsComment;
    protected LinearLayout imageNewsDetailsShouChang;
    protected LinearLayout imageNewsDetailsShare;
    protected ImageView authorIcon;
    protected TextView authorName;
    protected JCVideoPlayerStandard videoplayer;
    protected ImageView imageShouChang;
    protected boolean isShouChang = false;
    protected boolean isZan = false;

    String videoPath = "/storage/emulated/0/DCIM/movie/RIDEO_haiqu43877.mp4";

    @Override
    protected int getLayoutId() {
        return R.layout.activity_video_details;
    }

    @Override
    protected void initData() {
        GetEntertainmentListResInfo data = null;
        Bundle bundle = getIntent().getBundleExtra("bundle");
        if (bundle != null) {
            data = (GetEntertainmentListResInfo) bundle.getSerializable("data");
        }
        videoplayer.backButton.setVisibility(View.GONE);
        videoplayer.titleTextView.setVisibility(View.GONE);
        videoplayer.setUp(data == null ? videoPath : data.getSubject_ext(), JCVideoPlayer.SCREEN_LAYOUT_NORMAL, "");
        videoplayer.startPlayLogic();
        Help_VideoDetils_Content help_videoDetils_content = new Help_VideoDetils_Content(VideoDetailsActivity.this, null);
        recycleVideodetail.addHeaderView(help_videoDetils_content.getView());
        Help_VideoDetils_TuiJian help_videoDetils_tuiJian = new Help_VideoDetils_TuiJian(VideoDetailsActivity.this, null);
        recycleVideodetail.addHeaderView(help_videoDetils_tuiJian.getView());

        Adapter_List_VideoDetail adapter = new Adapter_List_VideoDetail(true, new Adapter_List_VideoDetail.CommentCallBack() {
            @Override
            public void call(int positon) {
                startActivity(new Intent(VideoDetailsActivity.this, CommentDetailsActivity.class));
            }

            @Override
            public void callZhan(int positon, TextView textView, ImageView imageView) {
                isZan = ClickUtils.clickZhan(VideoDetailsActivity.this, imageView, textView, isZan);
            }


            @Override
            public void callHuiFu(int positon) {

            }
        });
        recycleVideodetail.setAdapter(adapter);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.videoDetail_Back) {
            finish();
        } else if (view.getId() == R.id.detail_More) {

        } else if (view.getId() == R.id.image_NewsDetails_Write) {
            ClickUtils.clickComment(this, imageNewsDetailsWrite);

        } else if (view.getId() == R.id.image_NewsDetails_Comment) {

        } else if (view.getId() == R.id.image_NewsDetails_ShouChang) {
            isShouChang = ClickUtils.clickShouChang(this, imageShouChang, isShouChang);
        } else if (view.getId() == R.id.image_NewsDetails_Share) {
            ShareDialogUtils.showShareView(this, imageNewsDetailsShare, new ShareDialogUtils.SharePopCallBack() {
                @Override
                public void Call(AdapterView<?> adapterView, View view, int i, long l) {

                }
            });

        }
    }

    @Override
    protected void initView() {
        detailBack = (LinearLayout) findViewById(R.id.videoDetail_Back);
        detailBack.setOnClickListener(VideoDetailsActivity.this);
        detailMore = (LinearLayout) findViewById(R.id.videoDetail_More);
        detailMore.setOnClickListener(VideoDetailsActivity.this);
        //  recycleVideodetail = (RecyclerView) findViewById(R.id.recycle_videodetail);
        recycleVideodetail = (ListView) findViewById(R.id.recycle_videodetail);

        imageNewsDetailsWrite = (TextView) findViewById(R.id.image_NewsDetails_Write);
        imageNewsDetailsWrite.setOnClickListener(VideoDetailsActivity.this);
        imageNewsDetailsComment = (LinearLayout) findViewById(R.id.image_NewsDetails_Comment);
        imageNewsDetailsComment.setOnClickListener(VideoDetailsActivity.this);
        imageNewsDetailsShouChang = (LinearLayout) findViewById(R.id.image_NewsDetails_ShouChang);
        imageNewsDetailsShouChang.setOnClickListener(VideoDetailsActivity.this);
        imageNewsDetailsShare = (LinearLayout) findViewById(R.id.image_NewsDetails_Share);
        imageNewsDetailsShare.setOnClickListener(VideoDetailsActivity.this);
        authorIcon = (ImageView) findViewById(R.id.author_icon);
        authorName = (TextView) findViewById(R.id.author_name);
        videoplayer = (JCVideoPlayerStandard) findViewById(R.id.videoplayer);
        imageShouChang = (ImageView) findViewById(R.id.image_ShouChang);

    }

    @Override
    protected void onPause() {
        super.onPause();
        videoplayer.releaseAllVideos();
    }
}
